package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.service.AddressService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/address")
public class AddressController {
    @Reference
    private AddressService addressService;

    @RequestMapping("/getAddress")
    public Result getAddress(){
        List<Map> address=null;
        try {
             address = addressService.getAddress();
            System.out.println(address);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.GET_ADDRESS_FAILL);
        }
        return new Result(true,MessageConstant.GET_ADDRESS_SUCCESS,address);
    }
}
